var app = getApp()
Page({
  data: {
    user: {
      name: "小明",
      tel: "15245878794",
      local: "河南省平顶山市新华区龙翔大道",
      state: true
    },
    list: [],
    price: '',
    time: '',
    orderId: '',
    wait:false,
    done:false
  },
  onLoad: function (options) {
    let that = this
    // console.log(options.time)
    that.setData({
      // list: wx.getStorageSync('goods'),
      // price: wx.getStorageSync('price'),
      // time: options.time,
      orderId: options.id
    })
    wx.cloud.database().collection('location_list')
      // app.getList('location_list')
      .doc(wx.getStorageSync('id'))
      .get()
      .then(res => {
        // console.log("获取成功", res);
        that.setData({
          user: res.data
        })
      })
      .catch(res => {
        console.log("获取失败", res);
      })
    wx.cloud.database().collection('orderList')
      .doc(that.data.orderId)
      .get()
      .then(res => {
        // console.log(res.data.state)
        if(res.data.state==='待发货'){
          that.setData({
            wait:true
          })
        }
        if(res.data.state==='已收货'){
          that.setData({
            done:true
          })
        }
        that.setData({
          list: res.data.myOrder,
          price:res.data.price,
          time:res.data.time
        })
      })
  }
})